<?php

namespace App\Service\SearchService;

use App\Service\InterfaceService\BaseElasticSearchInterface;
class ElasticSearchService implements BaseElasticSearchInterface
{
    //索引表结构文件目录
    protected $IndexPath = "App\\Service\\SearchService\\Index\\";
    
    /**
     * 创建索引结构
     * @param array $params
     * @return mixed
     */
    public function putMapping( array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 删除索引结构
     * @param array $params
     * @return mixed
     */
    public function delMapping( array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}();
    }

    /**
     * 获取索引结构
     * @param array $params
     * @return mixed
     */
    public function getMapping( array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}();
    }
    

    /**
     * 新增文档数据
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function insertDoc(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 更新文档数据
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function updateDoc(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 删除文档数据
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function delDoc(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 异步批处理文档数据
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function bulkDocAsync(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 同步批处理文档数据
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function bulkDocSync(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 获取索引结构
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function searchDoc(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 搜索统计文档数据
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function countDoc(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
    
    /**
     * 搜索分组数据
     * @param arrray $params
     * $params['index'] = (string) 索引类名称 (Required)
     */
    public function groupDoc(array $params )
    {
        $classIndex = $this->IndexPath . $params['index'];
        return container()->get($classIndex)->{__FUNCTION__}($params);
    }
}